#include "Sensor.h"

Sensor::Sensor()
{
 	SId = 0;
}

 
bool Sensor::operator == (Sensor *s1 )
{
	return s1->SId == this->SId;
}

bool Sensor::operator != (Sensor *s1 )
{
	return s1->SId != this->SId;
}


 //SensorSmoke--------------------------------
SensorSmoke::SensorSmoke()
{
	TypeOfSensor type = TypeSmoke;
	int temp = (int) type;
	SId = temp << 16;
	SmokePoint = 0;
}

SensorSmoke::SensorSmoke(int roomid, float CP )  
{
	TypeOfSensor type = TypeSmoke;
 	int temp = (int) type;
	SId = temp << 16;
 	SId = SId | roomid;
  	SmokePoint  = CP;
}

void SensorSmoke::SetCP(float CP)
{
	SmokePoint = CP;
}

void SensorSmoke::CaptureSmokeDense(float SmokeDensity)  
{
	if (SmokeDensity > SmokePoint)  // the smokeDense exceeds the CriticalPoint , set the type of Msg to ExcptFire
		SMsg.MId = ExcptFire;
	else
		SMsg.MId = ExcptNone;
	SMsg.SId = SId;
 }

Msg SensorSmoke::ReturnMsg()
{
	return SMsg;
}

TypeOfSensor SensorSmoke::ReturnType()
{
	return TypeSmoke;
}

//SensorTemperature-----------------------
SensorTemperature::SensorTemperature()
{
	TypeOfSensor type = TypeTemperature;
	int temp = (int) type;
	SId = temp << 16;
	TemperaturePoint = 0;
}

SensorTemperature::SensorTemperature(int roomid,   float CP)
{
	TypeOfSensor type = TypeTemperature;
 	int temp = (int) type;
	SId = temp << 16;
 	SId = SId | roomid;
	TemperaturePoint = CP;
}

 
void SensorTemperature::SetCP(float CP)
{
	TemperaturePoint = CP;
}

void SensorTemperature::CaptureTemperature(float Temperature)
{
	if (Temperature > TemperaturePoint)
		SMsg.MId = ExcptFire;
	else
		SMsg.MId = ExcptNone;
	SMsg.SId = SId;
 }

Msg SensorTemperature::ReturnMsg()
{
	return SMsg;
}

TypeOfSensor SensorTemperature::ReturnType()
{
	return TypeTemperature;
}
//SensorCO----------------------------
SensorCO::SensorCO()
{
	TypeOfSensor type = TypeCO;
	int temp = (int) type;
	SId = temp << 16;
	COPoint = 0;
}

SensorCO::SensorCO(int roomid, float CP)
{
	TypeOfSensor type = TypeCO;
 	int temp = (int) type;
	SId = temp << 16;
 	SId = SId | roomid;
	COPoint = 0;
}

void SensorCO::SetCP(float CP)
{
	COPoint = CP;
}

void SensorCO::CaptureCODense(float CODensity)
{
	if (CODensity > COPoint)
		SMsg.MId = ExcptCO;
	else
		SMsg.MId = ExcptNone;
	SMsg.SId = SId;
 }

Msg SensorCO::ReturnMsg()
{
	return SMsg;
}

TypeOfSensor SensorCO::ReturnType()
{
	return TypeCO;
}
//SensorInfrared----------------------------------
SensorInfrared::SensorInfrared()
{
	TypeOfSensor type = TypeInfrared;
	int temp = (int) type;
	SId = temp << 16;
	InfraredPoint = 0;
}

SensorInfrared::SensorInfrared(int roomid, int CP)
{
	TypeOfSensor type = TypeInfrared;
 	int temp = (int) type;
	SId = temp << 16;
 	SId = SId | roomid;
	InfraredPoint = 0;
}

void SensorInfrared::SetCP(int CP)
{
	InfraredPoint = CP;
}

void SensorInfrared::CaptureInfrared(int Infra)
{
	if (Infra > InfraredPoint)
		SMsg.MId = ExcptBreakIn;
	else
		SMsg.MId = ExcptNone;
	SMsg.SId = SId;
	SMsg.Param1 = Infra;
}

Msg SensorInfrared::ReturnMsg()
{
	return SMsg;
}

TypeOfSensor SensorInfrared::ReturnType()
{
	return TypeInfrared;
}
//SensorStress-------------------------
SensorStress::SensorStress()
{
	TypeOfSensor type = TypeStress;
	int temp = (int) type;
	SId = temp << 16;
	StressPoint = 0;
}

SensorStress::SensorStress(int roomid, int CP)
{
	TypeOfSensor type = TypeStress;
 	int temp = (int) type;
	SId = temp << 16;
 	SId = SId | roomid;
	StressPoint = 0;
}

void SensorStress::SetCP(int CP)
{
	StressPoint = CP;
}

void SensorStress::CaptureStress(int Stress)
{
	if (Stress > StressPoint)
		SMsg.MId = ExcptBreakIn;
	else
		SMsg.MId = ExcptNone;
	SMsg.SId = SId;
	SMsg.Param1 = Stress;
}

Msg SensorStress::ReturnMsg()
{
	return SMsg;
}

TypeOfSensor SensorStress::ReturnType()
{
	return TypeStress;
}

//SensorOpenClose---------------------------
SensorOpenClose::SensorOpenClose()
{
	TypeOfSensor type = TypeOpenClose;
	int temp = (int) type;
	SId = temp << 16;
	OpCls = false;
}
SensorOpenClose::SensorOpenClose(int roomid, bool CP)
{
	TypeOfSensor type = TypeOpenClose;
 	int temp = (int) type;
	SId = temp << 16;
 	SId = SId | roomid;
	this->OpCls = CP;
}

 
void SensorOpenClose::CaptureOpCls(bool OC)
{
	OpCls = OC;
	SMsg.MId = ExcptNone;
 	SMsg.SId = SId;
	SMsg.Param1 = OC;
}

Msg SensorOpenClose::ReturnMsg()
{
	return SMsg;
}

TypeOfSensor SensorOpenClose::ReturnType()
{
	return TypeOpenClose;
}

//SensorWaterLvl--------------------------
SensorWaterLvl::SensorWaterLvl()
{
	TypeOfSensor type = TypeWaterLvl;
	int temp = (int) type;
	SId = temp << 16;
	WaterLvlPoint = 0;
}

SensorWaterLvl::SensorWaterLvl(int roomid, int CP)
{
	TypeOfSensor type = TypeWaterLvl;
 	int temp = (int) type;
	SId = temp << 16;
 	SId = SId | roomid;
	WaterLvlPoint = CP;
}

void SensorWaterLvl::SetCP(int CP)
{
	WaterLvlPoint = CP;
}

void SensorWaterLvl::CaptureWaterLvl(int Water)
{
	if (Water > WaterLvlPoint)
		SMsg.MId = ExcptWater;
	else
		SMsg.MId = ExcptNone;
	SMsg.SId = SId;
	SMsg.Param1 = Water;
}

Msg SensorWaterLvl::ReturnMsg()
{
	return SMsg;
}

TypeOfSensor SensorWaterLvl::ReturnType()
{
	return TypeWaterLvl;
}

 